package WaiBao;

import java.util.Arrays;

public class LianChenJin {
    public static void main(String[] args) {
        String[] name = {"肖兴义(班长)", "张裕爱(副班长)", "小李(学习委员)", "成道如(组织委员)", "杨幂之", "普松青", "李艾正", "欧晓", "凌瑞", "元奖", "李佳", "王德",
                "易学习", "和并举", "谢竞争", "田江文", "郑晓晓", "魏荣荣", "梁琼", "和丙烯", "成山", "冯永进", "余月柒", "方箅", "李元芳", "梅朝正", "林青霞", "高育良",
                "肖战", "连晨锦(学生)"};//考生本人:连晨锦(学生)
        int[] age = {18, 18, 22, 19, 20, 20, 21, 21, 19, 19, 18, 18, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 18};//考生年龄：18

        double[] w1 = {77, 78, 85, 80, 81, 69, 78, 99, 60, 80, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 89, 95};
        double[] w2 = {69, 81, 67, 65, 78, 87, 88, 69, 60, 90, 90, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 79, 84, 95};
        double[] w3 = {81, 89, 71, 65, 89, 75, 69, 69, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 94};

        double lily;//代表每个学生的总分
        double pea;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            lily = w1[i] + w2[i] +w3[i];
//            pea = (lily * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + lily);
//            System.out.println(name[i] + "的平均分为:" + pea);
//        }


        double pansy = 0, poppy = 0;
        double[] dahlia = new double[30];
//        for (int i = 0; i < 30; i++) {
//            pansy = w1[i] + w2[i] + w3[i];
//            poppy = ( pansy * 1.0) / 3;
//            dahlia[i] = poppy;
//        }
//
//        for (int i = 0; i < dahlia.length - 1; i++) {
//            for (int j = 0; j < dahlia.length - i - 1; j++) {
//                if (dahlia[j] < dahlia[j + 1]) {
//                    double temp = dahlia[j];
//                    dahlia[j] = dahlia[j + 1];
//                    dahlia[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(dahlia[i]);
//        }



        double pick1 = 0,pick2 = 0, pick3 = 0;//计算每门课的平均分
        double crocus1 = 0,  crocus2 = 0,  crocus3 = 0;//计算每门课标准差
        double iris1 = 0, iris2 = 0, iris3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < w1.length; i++) {
            sum2+=w1[i];
        }
        pick1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+pick1);
        double Sum = 0;
        for (int i = 0; i < w2.length; i++) {
            Sum+=w2[i];
        }
        pick2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+pick2);
        double sum = 0;
        for (int i = 0; i <w3.length; i++) {
            sum+=w3[i];
        }
        pick3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+pick3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < w1.length; i++) {
            c1+= (w1[i] -pick1)*(w1[i] - pick1);
        }
        crocus1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ crocus1);

        for (int i = 0; i < w2.length; i++) {
            c2+= (w2[i] -pick2)*(w2[i] - pick2);
        }
        crocus2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ crocus2);

        for (int i = 0; i < w3.length; i++) {
            c3+= (w3[i] - pick3)*(w3[i] - pick3);
        }
        crocus3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+ crocus3);

//        Arrays.sort(w1);
//        Arrays.sort(w2);
//        Arrays.sort(w3);
//        iris1 =( w1[14]+w1[15])*1.0/2;
//        iris2 =( w2[14]+w2[15])*1.0/2;
//        iris3 =( w3[14]+w3[15])*1.0/2;
//        System.out.println("分析化学的中位数为:"+iris1);
//        System.out.println("线性代数的中位数为:"+iris2);
//        System.out.println("有机化学学的中位数为:"+iris3);
    }
}
